/*
 ============================================================================
 Name        : Set_CGI.c
 Author      : liuzhanchun
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#if 1
#define SERVER_NAME cgiServerName
#endif
#if 0
#define SERVER_NAME "www.boutell.com"
#endif

/* You may need to change this, particularly under Windows;
	it is a reasonable guess as to an acceptable place to
	store a saved environment in order to test that feature.
	If that feature is not important to you, you needn't
	concern yourself with this. */

#ifdef WIN32
#define SAVED_ENVIRONMENT "c:\\cgicsave.env"
#else
#define SAVED_ENVIRONMENT "/tmp/cgicsave.env"
#endif /* WIN32 */

#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
#include "config_ini.h"
//系统管理
int cgiMain() {
	//local_ip=192.168.1.168
	configFileStrSet("/boa/my.ini","local_ip","192.168.1.168");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_ip","192.168.1.168");	

	//local_gateway=192.168.1.1
	configFileStrSet("/boa/my.ini","local_gateway","192.168.1.1");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_gateway","192.168.1.1");	

	//local_mask=255.255.255.0
	configFileStrSet("/boa/my.ini","local_mask","255.255.255.0");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_mask","255.255.255.0");

	//remote_ip=192.168.1.100
	configFileStrSet("/boa/my.ini","remote_ip","192.168.1.100");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","remote_ip","192.168.1.100");

	//remote_port=60800
	configFileStrSet("/boa/my.ini","remote_port","60800");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","remote_port","60800");

	//user_name=Admin
	configFileStrSet("/boa/my.ini","user_name","Admin");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","user_name","Admin");

	//user_password=123456
	configFileStrSet("/boa/my.ini","user_password","123456");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","user_password","123456");

	//language_setting=chinese
	configFileStrSet("/boa/my.ini","language_setting","chinese");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","language_setting","chinese");

	//maintenance=close_auto
	configFileStrSet("/boa/my.ini","maintenance","close_auto");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","maintenance","close_auto");

	//camera_line_number=40
	configFileStrSet("/boa/my.ini","camera_line_number","40");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_line_number","40");

	//whitebalance=open_balance
	configFileStrSet("/boa/my.ini","whitebalance","open_balance");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","whitebalance","open_balance");

	//camera_fusion_degree=192
	configFileStrSet("/boa/my.ini","camera_fusion_degree","192");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_fusion_degree","192");

	//camera_brightness=120
	configFileStrSet("/boa/my.ini","camera_brightness","40");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_brightness","120");

	//triggerinput_1=open_triggerinput_1
	configFileStrSet("/boa/my.ini","triggerinput_1","open_triggerinput_1");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","triggerinput_1","open_triggerinput_1");

	//triggerinput_2=open_triggerinput_2
	configFileStrSet("/boa/my.ini","triggerinput_2","open_triggerinput_2");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","triggerinput_2","open_triggerinput_2");

	//camera_delay=1
	configFileStrSet("/boa/my.ini","camera_delay","1");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_delay","1");

	//camera_HDMI_display=camera_HDMI_middle
	configFileStrSet("/boa/my.ini","camera_HDMI_display","camera_HDMI_middle");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_HDMI_display","camera_HDMI_middle");

	//marking_setting=close_marking_setting
	configFileStrSet("/boa/my.ini","marking_setting","close_marking_setting");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","marking_setting","close_marking_setting");

	//marking_number=2
	configFileStrSet("/boa/my.ini","marking_number","2");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","marking_number","2");

	//fisheyeCorrection=close_fisheyeCorrection
	configFileStrSet("/boa/my.ini","fisheyeCorrection","close_fisheyeCorrection");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","fisheyeCorrection","close_fisheyeCorrection");

	//camera_HDMI_display_switch=open
	configFileStrSet("/boa/my.ini","camera_HDMI_display_switch","open");
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_HDMI_display_switch","open");

	/* Send the content type, letting the browser know this is HTML */
	cgiHeaderContentType("text/html; charset=UTF-8");

	/* Top of the page */
	fprintf(cgiOut, "<HTML><HEAD>\n");
	fprintf(cgiOut, "<TITLE>web 管理</TITLE></HEAD>\n");
	fprintf(cgiOut, "<BODY><H1></H1>\n");

	//刷新页面
	fprintf(cgiOut, "<meta http-equiv=Refresh content=0;URL=../manager.html\n");
	fprintf(cgiOut, "</BODY></HTML>\n");

	return 0;
}

